import Vue from 'vue'
import VueRouter from 'vue-router'
import index from '../views/index.vue'

Vue.use(VueRouter)

const routes = [
  { path: '/', redirect: '/index' },
  {
    path: '/index',
    name: 'index',
    component: index,
  },
  {
    path: '/porcelain',
    name: '浙里有瓷',
    component: () => import('@/views/porcelain/index.vue'),
  },
  {
    path: '/tasty',
    name: '浙里有味',
    component: () => import('@/views/tasty/index.vue'),
  },
  {
    path: '/swiper',
    name: '轮播图',
    component: () => import('@/views/tasty/swiper.vue'),
  },
  {
    path: '/dramaList',
    name: '戏剧项目列表',
    component: () => import('@/views/drama/list.vue'),
  },
  {
    path: '/goodsXq',
    name: '浙里有味',
    component: () => import('@/views/drama/goodsXq.vue'),
  },
  {
    path: '/video',
    name: '视频',
    component: () => import('@/views/video/index.vue'),
  },
  {
    path: '/live',
    name: '视频',
    component: () => import('@/views/drama/live.vue'),
  },
  {
    path: '/fyVideoList',
    name: '浙江非遗看我的',
    component: () => import('@/views/video/fyVideoList.vue'),
  },
  {
    path: '/xjxmList',
    name: '戏剧项目点播列表',
    component: () => import('@/views/video/xjxmList.vue'),
  },
  {
    path: '/xjvideo',
    name: '戏剧项目点播',
    component: () => import('@/views/video/xjvideo.vue'),
  },
]

const router = new VueRouter({
  // mode:'history',
  routes
})
router.beforeEach((to,from,next)=>{//beforeEach是router的钩子函数，在进入路由前执行
  if(to.meta.title){//判断是否有标题
      document.title = to.meta.title
  }
  next()  //执行进入路由，如果不写就不会进入目标页
})
export default router
